<?php
class Function_model extends CI_Model {

	function __construct()
    {
        // Call the Model constructor
        parent::__construct();
        $this->load->database();
    }
	
	//function Function_model()
	//{
	//	parent::Model();
	//	$this->load->database();			
	//}

	function getSearchResults ($description = TRUE)
	{
		$function_name = '%to%';
		$this->db->orderby('function_name');
		$sql = sprintf("SELECT * FROM functions where function_name like '%s' order by function_name",
	    mysql_real_escape_string($function_name));
    
		$query = $this->db->query($sql);
		if ($query->num_rows() > 0) {
			$output = '<ul>';
			foreach ($query->result() as $function_info) {
				if ($description) {
					$output .= '<li><strong>' . $function_info->function_name . '</strong><br />';
					$output .= $function_info->function_description . '</li>';
				} else {
					$output .= '<li>' . $function_info->function_name . '</li>';
				}
			}
			$output .= '</ul>';
			return $output;
		} else {
			return '<p>Sorry, no results returned.</p>';
		}
	}

}
?>